const commentService = require('../service/Comment').model;
module.exports = function(router) {
  router.get('/obtain', async (ctx, next) => {
    const _id = ctx.query._id;
    const newsDoc = await commentService.obtainComment(_id);
    ctx.set('Cache-Control', 'no-store');
    ctx.body = newsDoc.toJSON();
  });
  router.get('/obtainAll', async (ctx, next) => {
    const commentDocList = await commentService.obtainAllComment();
    ctx.set('Cache-Control', 'no-store');
    ctx.body = commentDocList.map(doc => doc.toJSON());
  });
  return router;
}
